<template>
  <div class="container">
    <div>
      <span>这里用来查询今日头条</span>
    </div>
    <div>
      <el-table
        :data="listInfo"
        style="width: 100%">
        <el-table-column
          prop="title"
          label="标题">
        </el-table-column>
        <el-table-column
          prop="source"
          label="作者">
        </el-table-column>
        <el-table-column
          prop="verified_content"
          label="官方账号">
        </el-table-column>
        <el-table-column
          prop="abstract"
          label="内容">
        </el-table-column>
        <el-table-column
          prop="display_url"
          label="文章出处">
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { getNews } from '@/common/common'

export default {
  data() {
    return {
      listInfo:[]
    }
  },
  computed: {
    ...mapGetters([
      'roles'
    ])
  },
  mounted(){
    this.search();
  },
  methods:{
    search(){
      let params = {};
      getNews(params).then((res) => {
        if(res.status == 200) {
          let data = JSON.parse(res.data.body);
          for (let i = 0; i < data.data.length; i++) {
            data.data[i] = JSON.parse(data.data[i].content);
          }
          this.listInfo = data.data;
        }
      })
      .catch((err) => {
        console.log(err);
      })
    }
  }
}
</script>

<style>
.container {
  width: 100%;
  padding: 1%;
  margin: 0 auto;
}
</style>
